class Rectangle:
    def __init__(self, center_x, center_y, length, wide):
        self.center_x = center_x
        self.center_y = center_y
        self.length = length
        self.wide = wide
        self.left_edge, self.right_edge, self.up_edge, self.down_edge = 0, 0, 0, 0

    def confirm_edge(self):
        self.left_edge = self.center_x - self.length / 2
        self.right_edge = self.center_x + self.length / 2
        self.up_edge = self.center_y - self.wide / 2
        self.down_edge = self.center_y + self.wide / 2

    def confirm_crash(self, other_rec):
        self.confirm_edge()
        other_rec.confirm_edge()
        if ((self.left_edge <= other_rec.left_edge <= self.right_edge) or
            (self.left_edge <= other_rec.right_edge <= self.right_edge) or
            (other_rec.left_edge <= self.left_edge <= other_rec.right_edge) or
            (other_rec.left_edge <= self.right_edge <= other_rec.right_edge)) and \
                ((self.up_edge <= other_rec.up_edge <= self.down_edge) or
                 (self.up_edge <= other_rec.down_edge <= self.down_edge) or
                 (other_rec.up_edge <= self.up_edge <= other_rec.down_edge) or
                 (other_rec.up_edge <= self.down_edge <= other_rec.down_edge)):
            return True
        else:
            return False

    def move_x(self, dx):
        self.confirm_edge()
        new_rectangle = Rectangle(self.center_x, self.center_y, self.length, self.wide)
        new_rectangle.center_x += dx
        return new_rectangle

    def move_y(self, dy):
        self.confirm_edge()
        new_rectangle = Rectangle(self.center_x, self.center_y, self.length, self.wide)
        new_rectangle.center_y += dy
        return new_rectangle


def main():
    print("======Debug of Rectangle=======")
    dbRec1 = Rectangle(0, 0, 40, 20)
    dbRec2 = Rectangle(0, 15, 50, 9)
    print(dbRec1.confirm_crash(dbRec2))
    print("===============================")


main()
